home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / COLORDLG.PAK / CCTLTEST.CPP next >
C/C++ Source or Header  |  1997-05-06  |  2KB  |  74 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1995 by Borland International, All Rights Reserved
  4. //
  5. // This example uses the custom control and dialog box defined in colordlg.cpp
  6. //----------------------------------------------------------------------------
  7. #include <owl/pch.h>
  8. #include <owl/framewin.h>
  9. #include <owl/applicat.h>
  10. #include <classlib/pointer.h>
  11. #include <stdio.h>
  12. #include "cctltest.h"
  13. #include "colordlg.h"
  14.  
  15. //
  16. // class TTestApp
  17. // ~~~~~ ~~~~~~~~
  18. class TTestApp : public TApplication {
  19.   public:
  20.     TTestApp() : TApplication("Custom Control Test") {}
  21.  
  22.   private:
  23.     void   InitMainWindow();
  24.     void   CmColor();
  25.  
  26.     TColor Color;
  27.  
  28.   DECLARE_RESPONSE_TABLE(TTestApp);
  29. };
  30.  
  31. //
  32. //
  33. //
  34. DEFINE_RESPONSE_TABLE1(TTestApp, TApplication)
  35.   EV_COMMAND(CM_COLOR, CmColor),
  36. END_RESPONSE_TABLE;
  37.  
  38. //
  39. //
  40. //
  41. void
  42. TTestApp::InitMainWindow()
  43. {
  44.   MainWindow = new TFrameWindow(0, Name);
  45.   MainWindow->AssignMenu(IDM_APPMENU);
  46.   Color = 0;
  47. }
  48.  
  49. //
  50. //
  51. //
  52. void
  53. TTestApp::CmColor()
  54. {
  55.   TPointer<char> msg = new char[128];
  56.   if (TColorDialog(MainWindow, Color).Execute() == IDOK)
  57.     sprintf(msg,
  58.       "RGB intensities:\r\n\r\n Red: %d\r\n Green: %d\r\n Blue: %d",
  59.       Color.Red(), Color.Green(), Color.Blue());
  60.   else
  61.     strcpy(msg, "Cancelled");
  62.  
  63.   MainWindow->MessageBox(msg, Name, MB_OK);
  64. }
  65.  
  66. //
  67. //
  68. //
  69. int
  70. OwlMain(int /*argc*/, char* /*argv*/ [])
  71. {
  72.   return TTestApp().Run();
  73. }
  74.